home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / GNUST / !GNUst / st / Process < prev    next >
Text File  |  1991-09-13  |  2KB  |  93 lines

  1. "======================================================================
  2. |
  3. |   Process Method Definitions
  4. |
  5.  ======================================================================"
  6.  
  7.  
  8. "======================================================================
  9. |
  10. | Copyright (C) 1990, 1991 Free Software Foundation, Inc.
  11. | Written by Steve Byrne.
  12. |
  13. | This file is part of GNU Smalltalk.
  14. |
  15. | GNU Smalltalk is free software; you can redistribute it and/or modify it
  16. | under the terms of the GNU General Public License as published by the Free
  17. | Software Foundation; either version 1, or (at your option) any later version.
  18. | GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT
  19. | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  20. | FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  21. | details.
  22. | You should have received a copy of the GNU General Public License along with
  23. | GNU Smalltalk; see the file COPYING.  If not, write to the Free Software
  24. | Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  
  25. |
  26.  ======================================================================"
  27.  
  28.  
  29. "
  30. |     Change Log
  31. | ============================================================================
  32. | Author       Date       Change 
  33. | sbyrne     19 Sep 89      Converted to use real method categories
  34. |
  35. | sbyrne     25 Apr 89      created.
  36. |
  37. "
  38.  
  39. Link subclass: #Process
  40.      instanceVariableNames: 'suspendedContext priority myList'
  41.      classVariableNames: ''
  42.      poolDictionaries: ''
  43.      category: nil.
  44.  
  45. Process comment: 
  46. 'I represent a unit of computation.  My instances are independantly
  47. executable blocks that have a priority associated with them, and they
  48. can suspend themselves and resume themselves however they wish.' !
  49.  
  50. !Process class methodsFor: 'basic'!
  51.  
  52. on: aBlock at: aPriority
  53.     ^self new onBlock: aBlock at: aPriority
  54. !!
  55.  
  56.  
  57. !Process methodsFor: 'basic'!
  58.  
  59. terminate
  60.     | processList priority process |
  61.     suspendedContext _ nil.
  62.     myList notNil
  63.     ifTrue: [myList remove: self.
  64.          myList _ nil].
  65.     Processor activeProcess == self
  66.     ifTrue: [self suspend]
  67. "    myList remove: self"
  68. !!
  69.  
  70.  
  71.  
  72. !Process methodsFor: 'accessing'!
  73.  
  74. priority
  75.     ^priority
  76. !
  77.  
  78. priority: anInteger
  79.     priority _ anInteger
  80. !!
  81.  
  82.  
  83.  
  84. !Process methodsFor: 'private'!
  85.  
  86. onBlock: aBlock at: aPriority
  87.     suspendedContext _ aBlock.
  88.     priority _ aPriority
  89.  
  90. !!
  91.